<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML>
<html>
<head>
<title>My JSP 'result.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="assets/ico/biologo.ico" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap-popover.js"></script>
<script type="text/javascript" src="js/bootstrap-alert.js"></script>
<script type="text/javascript" src="js/bootstrap-scrollspy.js"></script>

<style type="text/css">
body {
	background-image: url("");
	font-family: 方正静蕾简体;
}

#diseases {
	
	position: absolute;
	top:0px;
	width: 700px;
	margin-top: 310px;
	margin-left: 360px;
}

form {
	font-size: 16px;
}

#titlediv {
	margin-bottom: 0px;
}

.content {
	padding-left: 18px;
	background-color: #E8F5F7;
}

.add-on {
	font-size: 14px;
}

.form-actions {
	margin-right: 52%;
}

.scrollspy-example {
	height: 200px;
	overflow: auto;
	position: relative;
}
</style>
</head>
<body>
	<%@ include file="main.jsp"%>

	<div id="diseases">
		<form action="exportDiseaseList.action">
			<s:iterator var="entryMap" value="#request.map" status="st0">
				<%--隱藏的disease的主鍵 --%>
				<input class="hiddenSn" type="hidden"
					value="<s:property value='#entryMap.key.sn' />" />
				<div id="accordion2" class="accordion">
					<%--每個疾病對應的複選框 --%>
					<input type="checkbox" name="checkDisease"
						id="checkDisease<s:property value='#entryMap.key.sn' />"
						value="<s:property value='#entryMap.key.sn' />"  onclick="event1()"/>


					<%--疾病名對應的鏈接進行的跳轉 --%>
					<i class="icon-list"></i> <a class="accordion-toggle"
						href="searchResultPage.action?sn=<s:property value='#entryMap.key.sn'/>">
						<s:property value="#entryMap.key.name" /> </a>
				</div>
			</s:iterator>
		</form>
		<%--------------------------------------------------------------------------------------------------------- --%>
		<c:if test="${totalcount!=0 }">
			<c:if test="${not empty totalcount}">
				<span style="color: #999">找到相关的结果${totalcount}条,${maxPage}页,搜索共耗时：${time}秒</span>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
					style="cursor: pointer;" id="exportDiseaseList">导出列表</a>
					

				<div id="alertMessage1" class="alert alert-error fade" style="float: right;">
					您还没有选任何的疾病，无法导出列表!!!
					<button class="close" data-dismiss="alert">×</button> </div>
			</c:if>
			<div class="pagination">
				<ul>
					<li><a id="firstpage" rel="0" href="javascript:void(0)">首页</a>
					</li>
					<li><a id="before" href="javascript:void(0)">上一页</a></li>
					<c:forEach var="pagenum" items="${pagenum}">
						<li><a class="pagenum" rel="${pagenum}"
							href="javascript:void(0)">${pagenum}</a>
						</li>
					</c:forEach>
					<li><a id="next" href="javascript:void(0)">下一页</a></li>
					<li><a id="lastpage" rel="${maxPage-1}"
						href="javascript:void(0)">尾页</a></li>
				</ul>
			</div>
		</c:if>
		<c:if test="${totalcount==0 }">

			<div class="alert alert-error">
				<button class="close" data-dismiss="alert">×</button>
				<strong>Warning!</strong> 您要查的不存在，或者说您输入有误！！！！
			</div>

		</c:if>

		<%--分页的隐藏域 --%>
		<input id="nowpage" type="hidden" style="display:none"
			value="${nowPage} " /> <input id="hiddensearchname" type="hidden"
			style="display:none" value="${searchname}" />
	</div>
</body>
<script type="text/javascript" charset="gbk">
	$(function() {
		$("#advancedSearch").click(function(){
			$("#diseases").css("display","none");
		});
		$("#searchSampleInfo").click(function(){
			$("#diseases").css("display","none");
		});
		$("#quickSearch").click(function(){
			$("#diseases").css("display","block");
		});
		
		
		$("#exportDiseaseList").click(
				function() {
					var list = 0;
					$(".hiddenSn").each(
						function() {
							var diseaseSn = $(this).val();
							if ($("input[id='checkDisease"+ diseaseSn + "']").attr("checked") != null) {
								list = list + 1;
							}
						});
					if (list == 0) {
						$("#alertMessage1").addClass(" in");
						return false;
					}

					$("form").submit();
				});

	});
	$(function() {
		$("#advancedSearch").click(function() {
			$("#diseases").hide();
			$.post("anvencedsearch.action");
		});
		$("#before").click(
				function() {
					var nowP = parseInt($("#nowpage").val());
					if (nowP == 0) {
						return false;
					}
					nowP = nowP - 1;
					if (nowP < 0) {
						nowP = 0;
					}
					window.location.href = "quickSearch.action?nowPage=" + nowP
							+ "&searchname=" + $("#hiddensearchname").val();
				});
		$("#next").click(
				function() {
					var nextP = parseInt($("#nowpage").val());
					if (nextP == $("#lastpage").attr("rel")) {
						return false;
					}
					var m = parseInt($("#lastpage").attr("rel"));
					nextP = nextP + 1;
					if (nextP > m) {
						nextP = m;
					}
					window.location.href = "quickSearch.action?nowPage="
							+ nextP + "&searchname="
							+ $("#hiddensearchname").val();
				});

		$(".pagenum").click(
				function() {
					var page = $(this).attr("rel");
					if (parseInt(page) == (parseInt($("#nowpage").val()) + 1)) {
						return false;
					}
					window.location.href = "quickSearch.action?nowPage="
							+ (parseInt(page) - 1) + "&searchname="
							+ $("#hiddensearchname").val();
				});

		$("#firstpage").click(
				function() {
					if (parseInt($("#nowpage").val()) == ($("#firstpage")
							.attr("rel"))) {
						return false;
					}
					window.location.href = "quickSearch.action?nowPage="
							+ $("#firstpage").attr("rel") + "&searchname="
							+ $("#hiddensearchname").val();
					$("#firstpage").parent().addClass("active");
				});
		$("#lastpage").click(
				function() {
					if (parseInt($("#nowpage").val()) == ($("#lastpage")
							.attr("rel"))) {
						return false;
					}
					$("#hiddensearchname").val();
					window.location.href = "quickSearch.action?nowPage="
							+ $("#lastpage").attr("rel") + "&searchname="
							+ $("#hiddensearchname").val();
				});
	});
	$(function() {
		$(".btn-danger").click(function() {
			$(".well").popover("show");
		});
		$(".disease_type").click(
				function() {
					$.post("disease_type.action", {
						"sn" : $(this).attr("rel")
					}, function(data) {
						$("#diseaseTypevalue" + data.diseaseCategory.sn)
								.toggle();
						$("#diseaseTypevalueSub" + data.diseaseCategory.sn)
								.text(data.diseaseCategory.name);
					});
				});
	});
	/*$(".collapse").collapse();
	$('#navbar').scrollspy();*/
</script>
</html>
